package com.admin.servlet;

import com.admin.service.IAdminService;
import com.admin.service.impl.AdminServiceImpl;
import com.user.entity.School;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "SchoolListServlet", value = "/SchoolListServlet")
public class SchoolListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");

        IAdminService adminService = new AdminServiceImpl();
        List<School> schoolInfo = adminService.getSchoolInfo();
        request.setAttribute("schoollist", schoolInfo);
        request.getRequestDispatcher("Admin/SchoolList.jsp").forward(request, response);


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
